public class HomeWork04 {
    public static void main(String[] args) {
        int[] arr = {10, 12, 45, 90};
        int[] arrNew = new int[arr.length + 1];
        int index = 0;
        int numIndex = 23;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > numIndex) {
                index = i;
                break;
            }
        }

        for (int i = 0, j = 0; i < arrNew.length; i++) {
            if (i != index) {
                arrNew[i] = arr[j];
                j++;
            } else {
                arrNew[i] = numIndex;
            }
            System.out.printf("arr[%d] = %d\t", i, arrNew[i]);
        }
        arr = arrNew;
    }

    public static void main1(String[] args) {
        //法1
        int[] arr = {10, 12, 45, 90};
        int[] arrNew = new int[arr.length + 1];
        int index = 23;
        boolean flag = false;
        for (int i = 0, j = 0; i < arrNew.length; i++) {
            if (arr[j] < index || flag == true) {
                arrNew[i] = arr[j];
                j++;
            } else {
                arrNew[i] = index;
                flag = true;
            }
            System.out.printf("arr[%d] = %d\t", i, arrNew[i]);
        }
        arr = arrNew;
    }
}


